/*
 * Copyright (C) 2010 Demura Igor
 * DLisp project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package dlisp.ide;

import java.util.Random;

import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;

public class Main
{
    static class UIThread implements Runnable
    {
        @Override
        public void run()
        {
            setupSwingPresentation();

            MainFrame frame = new MainFrame();
            frame.center();
            frame.firstShow();
        }

        void setupSwingPresentation()
        {
            try
            {
                UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            }
            catch (UnsupportedLookAndFeelException e)
            {
                Logger.println("Native L&F not supported");
            }
            catch (Exception e)
            {
                Logger.println("Set system L&F failed: " + e.getMessage());
            }
            // UIManager.put("swing.boldMetal", Boolean.FALSE);
        }
    }
    
    public static void Test()
    {
        Random rnd = new Random(19);
        
        int[][] a = new int[10][8];
        for (int i = 0; i < 10; ++i)
        {
            for (int j = 0; j < 8; ++j)
            {
                a[i][j] = rnd.nextInt() % 40 + 50;
                System.out.print(a[i][j] + " ");
            }
            System.out.println();
        }
                
        int nDog = 100;
        for (int i = 0; i < 10; ++i)
        {
            int nMax = 0;
            for (int j = 0; j < 8; ++j)
            {
                if (a[i][j] > nMax)
                    nMax = a[i][j];                
            }
            System.out.println("Max=" + nMax);
            if (nMax < nDog)
                nDog = nMax;
        }
        
        int nHat = 0;
        for (int j = 0; j < 8; ++j)
        {
            int nMin = 100;
            for (int i = 0; i < 10; ++i)
            {
                if (a[i][j] < nMin)
                    nMin = a[i][j];                
            }
            if (nMin > nHat)
                nHat = nMin;
            System.out.println("Min=" + nMin);
        }
        
        System.out.println("with dog: " + nDog + ", with hat: " + nHat);
    }

    /**
     * @param args
     */
    public static void main(String[] args)
    {
        //Test();
        java.awt.EventQueue.invokeLater(new UIThread());
    }
}
